﻿
@using ZBJF.Warranty.WebProvider
@using ZBJF.Warranty.Common.Enums.InsuranceOrder
@using ZBJF.Warranty.Common.Enums.InsuranceProducts
@using ZBJF.Warranty.Common.Enums.Data
@using ZBJF.Warranty.Common.Enums.InsuranceOrder.Data
@{
    ViewBag.Title = "销售商产品列表";
}
@section Header{
    @Scripts.Render("~/bundles/datatable")
    @Styles.Render("~/Content/datatable")
}
@model ZBJF.Warranty.Model.SellerInsuranceProducts

<ul class="nav nav-tabs">
    <li class="active"><a href="/SellerInsuranceProducts/SellerInsuranceProducts">销售商产品列表</a></li>
</ul>
<form id="searchForm" class="breadcrumb form-search">
    <table class="keep-all">
        <tr>
            <th>销售商：</th>
            <td>
                @Html.DropDownList("SellerID", ConvertToSelector.Instance.SellerNameToSelectList())
            </td>
            <th>保险卡产品名称：</th>
            <td>
                @Html.TextBoxFor(c => c.ProductName, new {maxlength = 20, @class = "input-small"})
            </td>
            <th>创建时间：</th>
            <td colspan="1">
                <input id="CreateTimeStart" class="Wdate input-small" type="text" onfocus="var CreateTimeEnd = $dp.$('CreateTimeEnd'); WdatePicker({ onpicked: function () { CreateTimeEnd.focus(); }, maxDate: '#F{$dp.$D(\'CreateTimeEnd\')}' })" />
                <input id="CreateTimeEnd" class="Wdate input-small" type="text" onfocus="WdatePicker({ minDate: '#F{$dp.$D(\'CreateTimeStart\')}' })" />
            </td>
            <th>是否启用：</th>
            <td>
                <select class="selected" id="IsAvailable">
                    <option>请选择</option>
                    <option value="true">是</option>
                    <option value="false">否</option>
                </select>
            </td>
            <td style="padding-top: 10px; padding-left: 20px;">
                <input id="btnSubmit" class="btn btn-primary Search-R" type="button" value="查询" onclick="search();">
            </td>
        </tr>
    </table>
</form>
<div class="table-responsive dataTables_wrapper">
    <table id="sellerInsuranceProductsList" class="table table-striped table-bordered table-hover">
        <thead>
            <tr>
                <th width="20">序号</th>
                <th width="80">所属销售商</th>
                <th width="148">保险产品名称</th>
                <th width="80">零售价</th>
                <th width="100">经销商零售价</th>
                <th width="100">中保销售价</th>
                <th width="100">最大库存</th>
                <th width="100">限购数量</th>
                <th width="100">是否启用</th>
                <th width="100">创建时间</th>
                <th width="100">操作</th>
            </tr>
        </thead>
    </table>
</div>
@section scripts{
    <script type="text/javascript">
        var isSearch = false;
        $(function () {
            var objTable = $("#sellerInsuranceProductsList")
                .dataTable({
                    fnDrawCallback: function () {
                        ControlPermissionOperate();
                    },
                    "aaSorting": [[10, "desc"]],
                    "sAjaxSource": "/SellerInsuranceProducts/SellerInsuranceProducts",
                    aoColumns: [
                        {
                            "mData": null,
                            "bSortable": false,
                            "fnRender": function (nRow) {
                                return nRow.iDataRow + 1;
                            }
                        },
                    {
                        "mData": "SellersName", "fnRender": function (nRow) {
                            return "<a class='Detail-R' target='_blank'  href='/Sellers/Detail/" + nRow.aData.SellerId + "'>" + nRow.aData.SellersName + "</a>";;
                        }
                    },
                    {
                        "mData": "ProductName", "fnRender": function (nRow) {
                            return "<a class='Detail-R' onclick='Open(\"" + nRow.aData.InsuranceProductId + "\",\"" + nRow.aData.InsuranceProductPackageID + "\")'style='cursor: pointer;'>" + nRow.aData.ProductName + "</a>";;
                        }
                    },
                    { "mData": "SaleRetailPrice" },
                    { "mData": "InsuranceCompanyRetailPrice" },
                      { "mData": "ZBJFSalePrice" },
                    { "mData": "MaxSalesQty" },
                    { "mData": "IdentityCardLimitQty" },
                    { "mData": "ID" },
                    { "mData": "CreateTime" },
                    { "mData": "ID" }
                    ]
                    , "fnRowCallback": function (nRow, aData, iDisplayIndex) {
                        $('td:eq(8)', nRow).html(aData.IsAvailable ? bootStrapOkIncon : bootStrapRemoveIncon);
                        //var html = "<a class='Edit-R' target='_blank' href='/SellerInsuranceProducts/AddInsuranceProductPackage?insuranceProductPackage=" + aData.ID + "' title='edit'><i class='icon-edit'></i></a>";
                        var html = "<a class='Edit-R' href=\"javascript:UpdateStatus('" + aData.ID + "'," + !aData.IsAvailable + ",'/SellerInsuranceProducts/UpdateSellerInsuranceProductsStatus','sellerInsuranceProductsList')\" title='" + (aData.IsAvailable ? "禁用" : "启用") + "'>" + (aData.IsAvailable ? bootStrapRemoveIncon : bootStrapOkIncon) + "</a>";
                        $('td:eq(10)', nRow).html(html);
                    }
                });
        });
        function Open(insuranceProductId, insuranceProductPackageId) {
            insuranceProductId = insuranceProductId * 1;
            insuranceProductPackageId = insuranceProductPackageId * 1;
            var url = insuranceProductId > 0 ? "/InsuranceProducts/Edit?id=" + insuranceProductId + "&type=1" : "/SellerInsuranceProducts/Detail?insuranceProductPackageId=" + insuranceProductPackageId;
            layer.open({
                type: 2,
                title: '商家保险产品详情',
                shade: 0.8,
                area: ['80%', '600px'],
                content: url//iframe的url
            });
        }
        function search() {
            /*给查询对象赋值*/
            queryParamList.SellerId = $("#SellerID").val();
            queryParamList.ProductName = $("#ProductName").val().trim();
            queryParamList.IsAvailable = $("#IsAvailable").val();
            queryParamList.CreateTimeStart = $("#CreateTimeStart").val();
            queryParamList.CreateTimeEnd = $("#CreateTimeEnd").val();
            $("#sellerInsuranceProductsList").dataTable().fnDraw();
        }
    </script>

}

